from flask import Flask, send_from_directory, request, jsonify

app = Flask(__name__)


@app.route('/static/<path:path>')
def serve_static(path):
    return send_from_directory('static', path)


@app.route('/', defaults={'path': 'index.html'})
@app.route('/<path:path>')
def serve_page(path):
    return send_from_directory('.', path)

@app.route('/login.html')
def serve_login():
    return send_from_directory('.', 'login.html')

@app.route('/login', methods=['POST'])
def login():
    username = request.form['username']
    password = request.form['password']


    if username == '123' and password == '123':
        return '登录成功'
    else:
        return '用户名或密码错误'

@app.route('/register', methods=['POST'])
def register():
    username = request.form['username']
    password = request.form['password']

    # 在这里编写注册逻辑，将用户名和密码保存到数据库或其他持久化存储中

    # 假设注册成功
    response = {
        'status': 'success',
        'message': '注册成功'
    }
    return jsonify(response)



if __name__ == '__main__':
    app.run(host='127.0.0.1', port=8080)
